package entities;

import java.util.ArrayList;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

public class Device {
	private String deviceName;
	private String ipAddress;
	private String UUID;
	private DeviceType deviceType;
	private ArrayList<String> connectedDevices;

	
	public Device(){
		
	}
	
	//Getters
	public String getDeviceName() {
		return deviceName;
	}
	public String getIpAddress() {
		return ipAddress;
	}
	public String getUUID() {
		return UUID;
	}
	public DeviceType getDeviceType() {
		return deviceType;
	}
	public ArrayList<String> getConnectedDevices() {
		if(connectedDevices == null)
			connectedDevices = new ArrayList<String>();
			
		return connectedDevices;
	}

	//Setters
	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}
	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}
	public void setUUID(String UUID) {
		this.UUID = UUID;
	}
	public void setDeviceType(DeviceType deviceType) {
		this.deviceType = deviceType;
	}
	public void setConnectedDevices(ArrayList<String> connectedDevices) {
		this.connectedDevices = connectedDevices;
	}
	
	public void addDevice(String macAddress){
		if(this.connectedDevices == null)
			this.connectedDevices = new ArrayList<String>();
			
		this.connectedDevices.add(macAddress);
	}

	@Override
	public String toString() {
		String s = "Device Name: " + deviceName + "\n";
		s += "Device Type: " + deviceType + "\n"; 
		s += "IP Address: " + ipAddress + "\n";
		s += "UUID Address: " + UUID + "\n";
		if(connectedDevices != null){
		s += "Connected Devices: " + connectedDevices.size();
		}
		return s;
	}
}